import Vue from 'vue'
import Router from 'vue-router'
import Vuex from 'vuex'
import Home from '@/components/HelloFromVux'
import Home2 from '@/components/Hello'
import store from '@/vuex/store'
import flexbox from '@/components/Flexbox/Flexbox'
import Login from '@/components/Login/Login'
import Splash from '@/page/Splash'
Vue.use(Router)
Vue.use(Vuex)
const router = new Router({
    routes: [{
            path: '/',
            component: Splash
        },
        {
            path: '/login',
            component: Login
        },
        {
            path: '/hello1',
            component: Home
        },
        {
            path: '/hello2',
            component: Home2
        },
        {
            path: '/flexbox',
            component: flexbox
        }
    ]
})
router.beforeEach(function(to, from, next) {
    console.log(to.path)
    if (to.path == "/" || to.path == "/login") {
        console.log("login")
        store.commit('changUiStatus', false)
    } else {
        store.commit('changUiStatus', true)
    }

    store.commit('startLoadingStatus')
    next()

})
router.afterEach(function(to) {

    let that = this
    setTimeout(function() {
        store.commit('stopLoadingStatus')
    }, 300)
})
export default router